import {User} from '../models/user';
import {Injectable} from 'angular2/core';
import {Photo} from '../models/photo';
import {Http, Headers} from 'angular2/http';

@Injectable()
export class UserService {
  constructor (private http:Http) {}

  getUserByName(username: string) {
    let url="http://localhost:5000/api/user/userName";
    let header=new Headers({ 'Content-Type': 'application/json','Authorization': 'Bearer '+localStorage.getItem("token")});
    let data={"UserName":username};
    return this.http.post(url, JSON.stringify(data), {headers: header});
  }

  updateUser(user: User) {
    let url="http://localhost:8080/rest/user/update";
    let header=new Headers({'Content-Type': 'application/json', 'Authorization': 'Bearer '+localStorage.getItem("token")});

    return this.http.post(url, JSON.stringify(user), {headers: header});
  }

  getSharedUser(user: User){

    let url="http://localhost:5000/api/user/shareduser";
    let header=new Headers({ 'Content-Type': 'application/json','Authorization': 'Bearer '+localStorage.getItem("token")});
    return this.http.post(url, JSON.stringify(user), {headers: header});
  }
}
